package com.labichaoka.chaoka.ui.home.fragment.my;

import com.labichaoka.chaoka.entity.BaseResponse;
import com.labichaoka.chaoka.entity.GetDepositBalanceInfo;
import com.labichaoka.chaoka.entity.OverdueAndIdcardResponse;

/**
 * Created by ruan on 2018/8/1.
 */

public class MyFragmentPresenterImpl implements MyFragmentPresenter,MyFragmentInteractor.OnInitFinishedListener {
    private MyFragmentInteractor myFragmentInteractor;
    private MyFragmentView myFragmentView;

    public MyFragmentPresenterImpl(MyFragmentInteractor interactor,MyFragmentView view){
        this.myFragmentInteractor=interactor;
        this.myFragmentView=view;
    }
    @Override
    public void init() {
        if (myFragmentView!=null){
            myFragmentView.showProgress();
        }
        myFragmentInteractor.overdueAndIdcard(this);
    }

    @Override
    public void getDepositBalanceInfo() {
        if (myFragmentView!=null){
            myFragmentView.showProgress();
        }
        myFragmentInteractor.getDepositBalanceInfo(this);
    }

    @Override
    public void onDestroy() {
        myFragmentView=null;
    }

    @Override
    public void onSuccess(OverdueAndIdcardResponse response) {
        myFragmentView.hideProgress();
        myFragmentView.setData(response);
    }

    @Override
    public void onFailed() {
        myFragmentView.hideProgress();
    }

    @Override
    public void onBalanceInfoSucc(GetDepositBalanceInfo response) {
        myFragmentView.hideProgress();
        myFragmentView.getDepositBalanceInfoCallback(response);
    }

    @Override
    public void onBalanceInfoFailed() {
        myFragmentView.hideProgress();
    }
}
